package cn.topevery.garden.dal.logic;

import cn.topevery.garden.dal.dao.DingtalkAttendanceScheduleDao;
import cn.topevery.garden.entity.po.DingtalkAttendanceSchedule;
import cn.topevery.garden.entity.query.DingtalkAttendanceScheduleQuery;
import cn.topevery.garden.entity.vo.DingtalkAttendanceScheduleVO;
import cn.topevery.garden.entity.vo.DingtalkWorkScheduleUserVO;
import cn.topevery.garden.entity.vo.DingtalkWorkScheduleVO;
import cn.topevery.garden.framework.base.BaseLogic;
import hw.topevery.framework.db.base.BaseEntityDao;
import hw.topevery.framework.db.entity.DataPager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.util.List;
import java.util.Map;

/**
 * 
 *
 * @author code-generate
 * @date 2021-09-02
 */
@Service
public class DingtalkAttendanceScheduleLogic extends BaseLogic<DingtalkAttendanceSchedule> {
    @Autowired
    DingtalkAttendanceScheduleDao dingtalkAttendanceScheduleDao;

    @Override
    public BaseEntityDao<DingtalkAttendanceSchedule, Integer> getDao() {
        return dingtalkAttendanceScheduleDao;
    }

    

    /**
     * 获取列表
     *
     * @param query
     */
    public DataPager<DingtalkAttendanceScheduleVO> listPage(DingtalkAttendanceScheduleQuery query) {
        return dingtalkAttendanceScheduleDao.listPage(query);
    }

    /**
     * 根据自增id批量删除
     *
     * @param ids
     */
    public void deleteBatchById(String userId,Integer[] ids) {
        dingtalkAttendanceScheduleDao.delete(userId, ids);
    }

    /**
     * 根据自增id保存或者更新
     *
     * @param dingtalkAttendanceSchedule 实体
     */
    public void saveOrUpdate(String userId, DingtalkAttendanceSchedule dingtalkAttendanceSchedule){
        dingtalkAttendanceScheduleDao.saveOrUpdate(userId,dingtalkAttendanceSchedule);
    }

    public void truncate() {
        dingtalkAttendanceScheduleDao.truncate();
    }

    public DingtalkAttendanceSchedule getEntity(LocalDate workDay, String userId){
        return dingtalkAttendanceScheduleDao.getEntity(workDay,userId);
    };

    public LocalDate getMaxDate() {
        return dingtalkAttendanceScheduleDao.getMaxDate();
    }

    public List<Map<String, Object>> getSyncUser(LocalDate begin) {
        return dingtalkAttendanceScheduleDao.getSyncUser(begin);
    }

    public DataPager<DingtalkWorkScheduleUserVO> findAllUserPage(int page, int pageSize, String name) {
        return dingtalkAttendanceScheduleDao.findAllUserPage(page, pageSize, name);
    }

    public List<DingtalkWorkScheduleVO> selectScheduleByDate(String date) {//date="yyyy-MM"
        return dingtalkAttendanceScheduleDao.selectScheduleByDate(date);
    }
}
